package com.thz.friend.controller.blog;

import com.thz.common.core.controller.BaseController;
import com.thz.common.core.result.Result;
import com.thz.friend.pojo.blog.Blog;
import com.thz.friend.pojo.blog.vo.BlogDetailsVO;
import com.thz.friend.pojo.blog.vo.BlogVO;
import com.thz.friend.service.blog.IBlogService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description
 * @Author thz
 * @Date 2025/5/11
 */
@Slf4j
@RestController
@RequestMapping("/blog")
@Tag(name = "文章接口")
public class BlogController extends BaseController {

    @Autowired
    private IBlogService blogService;

    @GetMapping("/list")
    public Result<List<BlogVO>> list(@NonNull @RequestParam("courseId") Long courseId){
        return Result.ok(blogService.list(courseId));
    }

    @GetMapping("/getBlogDetail")
    public Result<BlogDetailsVO> getBlogDetail(@NotNull @RequestParam("blogId") Long blogId,@NonNull @RequestParam("courseId") Long courseId){
        log.info("获取博客详情{}", blogId);
        return Result.ok(blogService.getBlogDetail(blogId, courseId));
    }


}
